package org.activequant.container.context;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * The default bean-list allows the user to explicitly define beans which are used for injection.<br/>
 * Holds the following associated variable:
 * <ul>
 * <li>objects(Set&lt;Object&gt;)</li>
 * </ul>
 * <br/><br/>
 * <ul>
 * <li>if name is spec'ed - lookup by name and return</li>
 * <li>else lookup by class. if single - return</li>
 * <li>if multiple - consult List. if in list, return it</li>
 * <li>else throw "ambiguity exception"</li>
 * </ul>
 * <br>
 * <b>History:</b><br>
 *  - [18.01.2008] Created (Erik Nijkamp)<br>
 *
 *  @author Erik Nijkamp
 */
public class DefaultBeanList {
	/**
	 * private Set&lt;Object&gt; objects = new HashSet&lt;Object&gt;();
	 */
	private Set<Object> objects = new HashSet<Object>();
	/**
	 * Constructs a DefaultBeanList and adds the given objects(Object...) to its associated objects(Set&lt;Object&gt;)
	 * @param objects
	 */
	public DefaultBeanList(Object... objects) {
		this.objects.addAll(Arrays.asList(objects));
	}
	/**
	 * returns an Object[] array holding the associated objects(Set&lt;Object&gt;)
	 * @return
	 */
	public Object[] getObjects() {
		return objects.toArray();
	}
	/**
	 * returns whether the associated objects(Set&lt;Object&gt;) contains the given object(Object)
	 * @param object
	 * @return
	 */
	public boolean contains(Object object) {
		return objects.contains(object);
	}

}
